n = int(input())
s = sorted(set(map(int, input().split())))
if len(s) > 3:
print(-1)
elif len(s) == 3:
if s[2] - s[1] == s[1] - s[0]:
print(s[2] - s[1])
else:
print(-1)
elif len(s) == 2:
if (s[1] - s[0]) % 2:
print(s[1] - s[0])
else:
print((s[1] - s[0]) // 2)
elif len(s) == 1:
print(0)
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f, MOD = 998244353; //1e9+7
const int INF_INT = 0x3f3f3f3f;
const long double PI = acosl(-1.), EPS = 1e-9;
using namespace std;
//cout << fixed << setprecision(6)
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("in", "r", stdin); //test input
int n;
cin >> n;
vector<int> v(n);
for(int i=0;i<n;i++) cin >> v[i];
bool ok = false;
for(int d=0;d<100;d++){
bool cok=false;
for(int val=1;val<=100;val++){
cok = true;
for(int i=0;i<n;i++){
if(v[i] == val || v[i]-d == val || v[i]+d == val) continue;
else{ cok = false; break;}
}
if(cok) break;
}
if(cok){
ok = true;
cout << d;
return 0;
}
}
cout << -1;
}
734A - Anton and Danik | 1300B - Assigning to Classes |
1647A - Madoka and Math Dad | 710A - King Moves |
1131A - Sea Battle | 118A - String Task |
236A - Boy or Girl | 271A - Beautiful Year |
520B - Two Buttons | 231A - Team |
479C - Exams | 1030A - In Search of an Easy Problem |
158A - Next Round | 71A - Way Too Long Words |
160A - Twins | 1A - Theatre Square |
1614B - Divan and a New Project | 791A - Bear and Big Brother |
1452A - Robot Program | 344A - Magnets |
96A - Football | 702B - Powers of Two |
1036A - Function Height | 443A - Anton and Letters |
1478B - Nezzar and Lucky Number | 228A - Is your horseshoe on the other hoof |
122A - Lucky Division | 1611C - Polycarp Recovers the Permutation |
432A - Choosing Teams | 758A - Holiday Of Equality |